package com.example.mingyue.context;

/**
 * 基础上下文，主要用于在同一个请求中获取userid
 */
public class BaseContext {

    public static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    //拦截器设置userid
    public static void setCurrentId(Long id) {
        threadLocal.set(id);
    }

    //userController获取userId,以获取userInfo登录时保持userInfo
    public static Long getCurrentId() {
        return threadLocal.get();
    }

    public static void removeCurrentId() {
        threadLocal.remove();
    }
}
